//
//  BVEmptyShoppingCart.m
//  BuyVegetable
//
//  Created by yushanchang on 16/10/15.
//  Copyright © 2016年 com.yinding. All rights reserved.
//  购物车为空视图

#import "BVEmptyShoppingCarts.h"
#import "UIView+Extension.h"

@interface BVEmptyShoppingCarts ()

@end

@implementation BVEmptyShoppingCarts

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI {

    UILabel *titleLabel = [[UILabel alloc] init];
    [titleLabel setWidth:ScreenW - 100];
    [titleLabel setHeight:25];
    [titleLabel setX:(ScreenW - titleLabel.width) / 2];
    [titleLabel setY:100];
    [titleLabel setText:@"您的购物车还是空的"];
    [titleLabel setFont:[UIFont systemFontOfSize:20]];
    [titleLabel setTextColor:[UIColor BVTextLightGrayColor]];
    [titleLabel setTextAlignment:NSTextAlignmentLeft];
    [self addSubview:titleLabel];
    
    UILabel *subTitleLabel = [[UILabel alloc] init];
    [subTitleLabel setX:titleLabel.frame.origin.x];
    [subTitleLabel setY:titleLabel.height + titleLabel.y + 10];
    [subTitleLabel setWidth:100];
    [subTitleLabel setHeight:25];
    [subTitleLabel setFont:[UIFont systemFontOfSize:20]];
    [subTitleLabel setText:@"赶紧行动吧"];
    [subTitleLabel setTextColor:[UIColor BVTextLightGrayColor]];
    [self addSubview:subTitleLabel];
    
    UIImageView *shoppingCart = [[UIImageView alloc] init];
    [shoppingCart setImage:[UIImage imageNamed:@"dagouwuche"]];
    [shoppingCart setX:subTitleLabel.x + subTitleLabel.width + 10];
    [shoppingCart setY:subTitleLabel.frame.origin.y-5];
    [shoppingCart setWidth:130];
    [shoppingCart setHeight:125];
    [self addSubview:shoppingCart];
    
    UIButton *shoppingButton = [[UIButton alloc] init];
    [shoppingButton setX:subTitleLabel.x];
    [shoppingButton setY:subTitleLabel.y + subTitleLabel.height + 45];
    [shoppingButton setWidth:120];
    [shoppingButton setHeight:40];
    [shoppingButton.layer setMasksToBounds:YES];
    [shoppingButton.layer setCornerRadius:3];
    [shoppingButton setTitle:@"马上去购物" forState:UIControlStateNormal];
    [shoppingButton setTag:888];
    [shoppingButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [shoppingButton setBackgroundColor:[UIColor BVBaseOrangeColor]];
    [shoppingButton addTarget:self action:@selector(shoppingClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:shoppingButton];
    
}

- (void)shoppingClick:(UIButton *)button {
    if (self.emptyClick) {
        self.emptyClick();
    }
}

@end
